import { IFeidaoAiBrowserComponent } from '@dfeidao/atom-web/interfaces';
import get from '@dfeidao/atom-web/local/get';
import set from '@dfeidao/atom-web/local/set';
// import { remove } from '@dfeidao/core/dom';
// import { IHandle } from '@dfeidao/core/on';
import a015 from './a015';
interface Aa {
	param: {
		id: object[]
	};
	order: object[];
	id: string;
}
interface Bb {
	param: {
		id: HTMLElement
	};
	order: HTMLElement;
}
export default async function a019(fd: IFeidaoAiBrowserComponent, args: { target: HTMLElement }) {
	// 删除筛选条件
	const id = args.target.dataset.feidaoId;

	const condition_node = get(fd, 'condition_node') as Bb;
	const condition_evt = get(fd, 'condition_evt') as Aa;
	const criteria = get(fd, 'criteria') as Aa;
	const sort = get(fd, 'sort') as Aa;

	if (id === "order") {
		delete condition_node.order;
		// (condition_evt.order[0]).destroy(); 不需sa
		delete condition_evt.order;
		const o_node = fd.data.node.querySelector("#condition_order");
		o_node.parentNode.removeChild(o_node);
		delete sort.order;
	} else {
		delete condition_node.param[id];
		// ((condition_evt.param[id])[0]).destroy();
		delete condition_evt.param[id];
		const r_node = fd.data.node.querySelector("#condition_" + id);
		r_node.parentNode.removeChild(r_node);
		delete criteria[id];
	}
	set(fd, 'sort', {});
	set(fd, 'condition_node', condition_node);
	set(fd, 'condition_evt', condition_evt);
	set(fd, 'criteria', criteria);
	await a015(fd);
}
